package haven.javafx.module.base;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by hewen on 2017/7/7.
 */
public class Viewbox {
    private static Map<Object,Object> map=new ConcurrentHashMap<Object,Object>();

    public static <T> T get(Class c){
        if(map.get(c.getSimpleName())==null){
            try {
                T o = (T) c.newInstance();
                map.put(c.getSimpleName(),o);
                return o;
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return (T) map.get(c.getSimpleName());
    }
}
